package com.yunlankeji.stemcells.activity.home;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.yunlankeji.ganxibaozhijia.R;
import com.yunlankeji.stemcells.activity.mine.Address_editActivity;
import com.yunlankeji.stemcells.adapter.Expert_databaseAdapter;
import com.yunlankeji.stemcells.adapter.Organization_mainAdapter;
import com.yunlankeji.stemcells.adapter.Organization_menuAdapter;
import com.yunlankeji.stemcells.model.request.Organization_menu;
import com.yunlankeji.stemcells.model.request.Organization_mian;

import java.net.CookieHandler;
import java.util.ArrayList;
import java.util.GregorianCalendar;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class Home_organizationActivity extends AppCompatActivity {
    @BindView(R.id.iv_organization_menu)
    ImageView iv_menu;
    @BindView(R.id.tv_organization_menu)
    TextView tv_menu;
    @BindView(R.id.tv_organization_name)
    TextView tv_organization_name;
    @BindView(R.id.tv_organization_fans)
    TextView tv_organization_fans;
    @BindView(R.id.iv_organization)
    ImageView iv_organizationn;

    private RecyclerView rv_organization_menu,rv_organization;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home_organization);


        rv_organization_menu = findViewById(R.id.rv_organization_menu);
        rv_organization = findViewById(R.id.rv_organization);

        List<Organization_menu>organization_menuList = new ArrayList<>();
        List<Organization_mian>organization_mianList = new ArrayList<>();


        Organization_menu organization_menu1 = new Organization_menu("干细胞中心",R.mipmap.icon_stem_cell_center);
        Organization_menu organization_menu2 = new Organization_menu("医美中心",R.mipmap.icon_medical_beauty);
        Organization_menu organization_menu3 = new Organization_menu("体检中心",R.mipmap.icon_medical);
        Organization_menu organization_menu4 = new Organization_menu("基因企业",R.mipmap.icon_gene);
        Organization_menu organization_menu5 = new Organization_menu("月子中心",R.mipmap.icon_lili);
        Organization_menu organization_menu6 = new Organization_menu("妇产医院",R.mipmap.icon_maternity);
        Organization_menu organization_menu7 = new Organization_menu("康养中心",R.mipmap.icon_health);
        Organization_menu organization_menu8 = new Organization_menu("医院",R.mipmap.icon_hospital);
        Organization_menu organization_menu9 = new Organization_menu("学会协会",R.mipmap.icon_association);
        Organization_menu organization_menu10 = new Organization_menu("更多",R.mipmap.icon_more);

        organization_menuList.add(organization_menu1);
        organization_menuList.add(organization_menu2);
        organization_menuList.add(organization_menu3);
        organization_menuList.add(organization_menu4);
        organization_menuList.add(organization_menu5);
        organization_menuList.add(organization_menu6);
        organization_menuList.add(organization_menu7);
        organization_menuList.add(organization_menu8);
        organization_menuList.add(organization_menu9);
        organization_menuList.add(organization_menu10);

        GridLayoutManager gridLayoutManager = new GridLayoutManager(Home_organizationActivity.this,5);
        rv_organization_menu.setLayoutManager(gridLayoutManager);
        Organization_menuAdapter organization_menuAdapter = new Organization_menuAdapter(organization_menuList);

        rv_organization_menu.setAdapter(organization_menuAdapter);

        Organization_mian organization_mian1 = new Organization_mian("123","75.5W",R.mipmap.icon_p2);
        Organization_mian organization_mian2 = new Organization_mian("1234","654.5W",R.mipmap.icon_p3);
        Organization_mian organization_mian3 = new Organization_mian("1543","755465W",R.mipmap.icon_p2);
        Organization_mian organization_mian4 = new Organization_mian("65463","75245W",R.mipmap.icon_p2);
        Organization_mian organization_mian5 = new Organization_mian("126843","7564655W",R.mipmap.icon_p3);


        organization_mianList.add(organization_mian1);
        organization_mianList.add(organization_mian2);
        organization_mianList.add(organization_mian3);
        organization_mianList.add(organization_mian4);
        organization_mianList.add(organization_mian5);
        GridLayoutManager gridLayoutManager1 = new GridLayoutManager(Home_organizationActivity.this,2);
        rv_organization.setLayoutManager(gridLayoutManager1);
        Organization_mainAdapter organization_mainAdapter = new Organization_mainAdapter(organization_mianList);
        rv_organization.setAdapter(organization_mainAdapter);
        // 设置item及item中控件的点击事件
        //菜单
        organization_menuAdapter.setOnItemClickListener(new Organization_menuAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(View v, Organization_menuAdapter.ViewName viewName, int position) {
                switch (v.getId()){
                    case R.id.lt_organization_menu:
                        Intent intent = new Intent();
                        intent.putExtra("title",organization_menuList.get(position).getTv_menu());
                        intent.setClass(Home_organizationActivity.this,Home_organization_classifyActivity.class);
//                    startActivity(new Intent(Home_organizationActivity.this, Home_organization_classifyActivity.class));
                        startActivity(intent);
                        break;
                }

            }

            @Override
            public void onItemLongClick(View v) {

            }
        });


        //主列表

        organization_mainAdapter.setOnItemClickListener(new Organization_mainAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(View v, Organization_mainAdapter.ViewName viewName, int position) {

                switch (v.getId()){

                    case R.id.lt_organization:
                        Intent intent = new Intent();
                        intent.putExtra("title",organization_mianList.get(position).getTv_organization_name());
                        intent.putExtra("name",organization_mianList.get(position).getTv_organization_name());
                        intent.putExtra("picture",organization_mianList.get(position).getIv_organization());
                        intent.putExtra("fans",organization_mianList.get(position).getTv_organization_fans());
                        intent.setClass(Home_organizationActivity.this,Home_organization_detialActivity.class);
                        startActivity(intent);
                        break;
                }
            }

            @Override
            public void onItemLongClick(View v) {

            }
        });


    }


}